package com.titanrise.crm.controller.salesperson;

import com.titanrise.crm.environment.annotation.Autowired;
import com.titanrise.crm.environment.annotation.Controller;
import com.titanrise.crm.environment.annotation.FunctionConfig;
import com.titanrise.crm.environment.annotation.MenuConfig;
import com.titanrise.crm.environment.menu.MenuContext;
import com.titanrise.crm.environment.menu.action.Action;
import com.titanrise.crm.service.SalespersonService;

@Controller(basePath = "/salesperson")
public class SalespersonController {
    @Autowired
    private SalespersonService salespersonService;

    @MenuConfig(path = "/", exec = true)
    public Action index(MenuContext context) {
        return salespersonService.beforeEnter(context);
    }

    @FunctionConfig(path = "/", key = 1, description = "查看消息列表", divider = "")
    public Action index1(MenuContext context) {
        salespersonService.showMessages(context);
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 2, description = "处理客户请求")
    public Action index2(MenuContext context) {
        salespersonService.showUnhandledTrades(context);
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 3, description = "查看客户信息", divider = "")
    public Action index3() {
        return Action.JUMP_TO_MENU("/salesperson/showCustomers");
    }

    @FunctionConfig(path = "/showCustomers", key = 1, description = "查看所属客户信息")
    public Action showCustomers1(MenuContext context) {
        salespersonService.showBelongedCustomer(context);
        return Action.JUMP_TO_MENU("/salesperson/showCustomers");
    }

    @FunctionConfig(path = "/showCustomers", key = 2, description = "查看无所属客户信息")
    public Action showCustomers2(MenuContext context) {
        salespersonService.showNonBelongingCustomerAndSelect(context);
        return Action.JUMP_TO_MENU("/salesperson/showCustomers");
    }

    @FunctionConfig(path = "/showCustomers", key = 3, description = "返回", divider = "")
    public Action showCustomers3(MenuContext context) {
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 4, description = "查看订单信息")
    public Action index4(MenuContext context) {
        salespersonService.showConfirmedTrades(context);
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 5, description = "展示工作成果")
    public Action index5(MenuContext context) {
        salespersonService.showWorkResults(context);
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 6, description = "修改个人信息")
    public Action index6(MenuContext context) {
        salespersonService.modifyPersonalInformation(context);
        return Action.JUMP_TO_MENU("/salesperson");
    }

    @FunctionConfig(path = "/", key = 7, description = "登出", divider = "")
    public Action index7(MenuContext context) {
        salespersonService.beforeLeave(context);
        return Action.JUMP_TO_MENU("/");
    }
}
